{layout name="public/layout" /}
{include file='yxnavbar'}


<div class="main">
    {include file='sms/sms_header'}
    <div class="panel panel-info">
        <div class="panel-heading">
<!--            筛选 共{$total}次-->
            <span style="color: red;font-weight: bold;font-size: 16px;">
                {if $open_yx_sms==1}
                【 成功发送 {$used_sms} 条 ，消费 {$used_amount} 元】
                {else}
                 【 短信通知未开通 】 开通请到 "群发短信" => "短信配置" 中开启，如有疑问请联系客服！
                {/if}
            </span>
        </div>
        <div class="panel-body">
            <form action="./index.php" method="get" class="form-horizontal" role="form">
                <input type="hidden" name="c" value="site"/>
                <input type="hidden" name="a" value="entry"/>
                <input type="hidden" name="m" value="{$_P['m']}"/>
                <input type="hidden" name="do" value="{$do}"/>
                <input type="hidden" name="ac" value="search"/>
                <input type="hidden" name="op" value="display"/>
                <input type="hidden" name="themeid" value="{$themeid}"/>


<!--                <div class="form-group">-->
<!--                    <label class="col-xs-1 col-sm-1 col-md-1 control-label">发送状态</label>-->
<!--                    <div class="col-xs-11 col-sm-9 col-md-9">-->
<!--                        <div class="btn-group">-->
<!--                            {loop $status_list $row}-->
<!--                            <a href="{php echo createWebUrl('sms',array('op' => 'sendlog','themeid'=>$themeid,'status'=>$row['status']));}"-->
<!--                               class="btn {if $status == $row['status']}btn-primary{else}btn-default{/if}">-->
<!--                                {$row['name']}-->
<!--                                <span style="color: #ff0000">{$row['total']}</span>-->
<!--                            </a>-->

<!--                            {/loop}-->
<!--                        </div>-->
<!--                    </div>-->
<!--                </div>-->

                <div class="form-group">
                    <label class="col-xs-12 col-sm-3 col-md-1 control-label">关键字</label>
                    <div class="col-sm-9 col-xs-2 col-md-3">
                        <input class="form-control" name="search_data" placeholder="输入手机号、短信内容"
                               type="text" value="{$_P['search_data']}">
                    </div>

                    <div class="col-sm-3 col-lg-3 col-md-3 col-xs-6">
                        <button class="btn btn-default"><i class="fa fa-search"></i> 搜索</button>
                        <input type="hidden" name="__token__" value="{$Request.token}"/>
                        <a class="btn btn-warning btn-sm"
                           href="{php echo createWebUrl('sms',array('op' => 'display','themeid'=>$themeid));}"  title="编辑"><i class="icon-edit"></i>全部明细</a>
                    </div>
                </div>
            </form>
        </div>
    </div>
    <div class="tab-content">
        <div class="panel panel-default">
            <div class="panel-body table-responsive">
                <table class="table table-hover">
                    <thead class="navbar-inner">
                    <tr>
                        <th style="width: 80px;">任务ID</th>
                        <th style="width: 280px;">短信内容</th>
                        <th style="width: 80px;">号码数</th>
                        <th style="width: 80px;">成功数</th>
                        <th style="width: 80px;">失败数</th>
                        <th style="width: 80px;">计费数</th>
                        <th style="width: 80px;">计费</th>
                        <th style="width: 80px;">发送状态</th>
                        <th style="width: 80px;">操作人</th>
                        <th style="width: 80px;">操作ip</th>
                        <th style="width: 140px;">创建时间</th>
                        <th style="width: 140px;">到达时间</th>
                        <th style="width: 140px;">操作</th>
                    </tr>
                    </thead>
                    <tbody>
                    {loop $list $key  $item}
                    <tr>
                        <td>
                            <?php echo  $key+1 ?>
                        </td>
                        <td>
                            {if $item['content']!='即时提醒'}
                            【{php echo $brand ;}】
                            {/if}
                            {$item['content']}
                        </td>
                        <td>{$item['count']}</td>
                        <td>{$item['success']}</td>
                        <td>{$item['fail']}</td>
                        <td>{$item['sum_count']}</td>
                        <td>{$item['sum']}</td>
                        <td>
                            {if $item['status']==1}
                            <span class="label label-success">发送成功</span>
                            {elseif $item['status']==2}
                            <span class="label label-danger">发送失败</span>
                            {elseif $item['status']==6&& $item['fixed_time'] ==0}
                            <span class="label label-warning">发送中</span>
                            {elseif $item['status']==6 && $item['fixed_time'] >0}
                            <span class="label label-warning">未到时间</span>
                            {/if}
                        </td>

                        <td>{php echo $item['admin_name']?$item['admin_name']:'系统发送';}</td>
                        <td>{$item['ip']}</td>

                        <td>
                            {if $item['status']!=4 || $item['status']!=5}
                            {$item['created_at']}
                            {else}
                            {/if}
                        </td>
                        <td>
                            {if $item['status']==1}
                                    {$item['fixed_time']}
                            {/if}
                        </td>
                        <td>
                            <a class="btn btn-warning btn-sm"
                               href="{php echo createWebUrl('sms',array('op' => 'display','themeid'=>$themeid,'tradeId'=>$item['tradeId'],'status'=>0));}"  title="编辑"><i class="icon-edit"></i>明细</a>
                            {if $_G['isSuperAdmin'] && $item['tradeId']!='000000000000000000000'}
                            <a class="btn btn-info btn-sm" onclick="renew_status(this)" data-tradeid="{$item['tradeId']}"><i class="icon-edit"></i>手动更新状态</a>
                            {if $item['templateKey']=='notify' && $item['status']=='2'}
                            <a class="btn btn-success btn-sm" onclick="change_marketing(this)" data-tradeid="{$item['tradeId']}"><i class="icon-edit"></i>手动转营销</a>
                            {/if}
                            {/if}
                        </td>
                    </tr>
                    {/loop}
                    </tbody>
                </table>
            </div>
        </div>
    </div>
    {$pager}
</div>
<script  type="text/javascript">
    function change_marketing(e){
        var tradeId = e.getAttribute("data-tradeid");
        if(!tradeId){
            layer.msg('任务ID未找到');
            return ;
        }
        layer.confirm("确认转营销短信？", {}, function(){
            var inde = layer.load(2);
            var __input = {
                'codeDesc':'驳回',
                'taskId':tradeId,
            };
            $.ajax({
                url:"{php echo createWebUrl('sms',array('op' => 'change_marketing','themeid'=>$themeid));}",
                dataType:'json',
                method:'post',
                data:{
                    __input:__input
                },
                success:function (e) {
                    layer.close(inde);
                    if(e.error==200){
                        layer.msg(e.msg);
                        setTimeout(function () {
                            window.location.reload();
                        },1500);
                    }else{
                        layer.msg(e.msg);
                    }
                }
            })
        })
    }
    function renew_status(e){
        var tradeId = e.getAttribute("data-tradeid");
        layer.confirm("确认更新状态？", {}, function(){
            var inde = layer.load(2);
            $.ajax({
                url:"{php echo createWebUrl('sms',array('op' => 'renew','themeid'=>$themeid));}",
                dataType:'json',
                method:'post',
                data:{
                    tradeId:tradeId
                },
                success:function (e) {
                    layer.close(inde);
                    if(e.error==200){
                        layer.msg(e.msg);
                        setTimeout(function () {
                            window.location.reload();
                        },1500);
                    }else{
                        layer.msg(e.msg);
                    }
                }
            })
        })
    }
</script>
